from PIL import Image
"""打开图片"""
# image =Image.open('tt.png')
# image.format,image.size,image.mode
# ('png',(500,750),'RGB')
# image.show()
"""剪裁图片"""
# image =Image.open('tt.png')
# rect =80,20,310,360
# image.crop(rect).show()
"""生成缩略图"""
# image = Image.open('tt.png')
# size = 128,128
# image.thumbnail(size)
# image.show()
"""缩放和黏贴图片"""
# image1 = Image.open('pp.png')
# image2 = Image.open('tt.png')
# rect =80,20,310,360
# tt_head = image2.crop(rect)
# width,height = tt_head.size
# image1.paste(tt_head.resize((int(width/1.5),int(height/1.5))),(172,40))
"""旋转和翻转"""
# image = Image.open('tt.png')
# image.rotate(180).show()
# image.transpose(Image.FLIP_LEFT_RIGHT).show()
"""操作像素"""
# image = Image.open('tt.png')
# for x in range(80,310):
#     for y in range(20,360):
#         image.putpixel((x,y),(128,128,128))
#         image.show()
"""滤镜效果"""
from PIL import Image,ImageFilter
image = Image.open('tt.png')
image.filter(ImageFilter.CONTOUR).show()